package com.rrd.dw.mr.gzip.kafka;

import com.alibaba.fastjson.JSONObject;
import com.ucredit.babel.common.model.BaseModel;
import com.ucredit.babel.common.model.RecordType;
import com.ucredit.babel.common.model.fahai.v1.PuDaoFaHaiSiFaListRecord;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper.Context;

import java.io.IOException;
import java.util.List;

/**
 * 法海司法数据详情
 *
 * @author guoqiang
 */

public class PuDaoFaHaiSiFaDetailParse extends ParseBase {
    private Text val = new Text();
    private Text key = new Text();

    /**
     * 法海司法数据详情
     *
     * @param model
     * @throws IOException
     * @throws InterruptedException
     */
    @Override
    public boolean parseJob(Context context, BaseModel<?> model, String successful) throws IOException, InterruptedException {
        PuDaoFaHaiSiFaListRecord obj = (PuDaoFaHaiSiFaListRecord) model;
        StringBuilder sb = getBaseInfo(obj, successful);

        StringBuilder TxSb = new StringBuilder(500);
		sb.append(formatValue(obj.getMsg())).append(CRT001);
		sb.append(formatValue(obj.getCode())).append(CRT001);
		sb.append(formatValue(obj.getSearchSeconds())).append(CRT001);
		StringBuilder txSb = getBaseInfo(obj);
		List<JSONObject> allList = obj.getAllList();
		for(JSONObject allObj: allList){
			TxSb.delete(0, TxSb.length());
			TxSb.append(formatValue(allObj.getString("entryId"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("matchRatio"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("sortTimeString"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("dataType"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("body"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("caseNo"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("caseNoKwordT"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("partyType"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("pname"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("ruleMainType"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("ruleSubType"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("signalDescV001"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("signalRatingV001"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("signalRuleNo"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("signalRuleVersion"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("sortTime"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("title"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("actionObject"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("address"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("age"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("ajlcStatusT"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("birthday"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("boHui"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("caf"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("caseCauseT"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("caseStateT"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("caseTypeT"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("cdk"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("chaiChu"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("cheSu"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("closeDate"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("court"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("courtRankT"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("courtroom"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("courtS"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("courtTypeT"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("diaoXiao"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("execMoney"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("faKuan"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("ggTypeT"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("guoHu"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("idcardNo"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("jieChuCDK"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("jingGao"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("jtqx"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("judge"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("judgeResult"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("juLiu"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("lawOffice"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("lawyer"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("layout"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("lxqkT"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("money"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("moShou"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("organizer"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("partyFeeT"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("partyPositionT"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("partyResultT"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("partyTitleT"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("piaoJuWX"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("poChanCZ"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("pochanHJ"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("poChanQS"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("postTime"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("proposer"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("province"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("qangZhi"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("qangZhiZX"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("qianChu"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("queRenWF"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("queRenWX"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("shiXin"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("tingChanTY"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("trialProcedure"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("trialProcedureS"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("yiju"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("yiwu"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("yjCode"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("yjdw"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("zhongBen"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("zhongZhi"))).append(CRT001);
			TxSb.append(formatValue(allObj.getString("zjzx"))).append(CRT001);
			key.set(getKey());
			val.set((sb.toString() + TxSb.toString() + txSb.toString()).replace("\n", " ").replace("\r", " "));
			context.write(key, val);
		}
        return true;
    }

    @Override
    public String getTableName() {
        return "kafka_babel_pu_dao_fa_hai_si_fa_detail_inc";
    }

	@Override
	public String getSubType() {
		return ".detail";
	}

    @Override
    public String getType() {
        return RecordType.PD_FA_HAI_SI_FA_LIST_RECORD.toString();
    }

    @Override
    public String getComment() {
        return "法海司法数据详情";
    }
}
